Centos安装docker显示 No Package Docker-Ce Available

查看当前系统内核
查看方式

1
uname -r

显示如下

1
2
[root@localhost home]# uname -r
3.10.0-957.el7.x86_64

重要提示: docker内核版本必须是3.10+以上的版本

  1. 卸载老版本的 docker 及其相关依赖
    1
    yum remove docker docker-common container-selinux docker-selinux docker-engine
1
2
3
4
5
6
7
8
[root@localhost home]# yum remove docker docker-common container-selinux docker-selinux docker-engine
Loaded plugins: fastestmirror, langpacks
No Match for argument: docker
No Match for argument: docker-common
No Match for argument: container-selinux
No Match for argument: docker-selinux
No Match for argument: docker-engine
No Packages marked for removal

2.更新yum

1
yum update

之后需要一段时间更新

3.安装 yum-utils,它提供了 yum-config-manager,可用来管理yum源

1
yum install -y yum-utils
1
2
3
4
5
6
7
8
[root@localhost home]#  yum install -y yum-utils
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.huaweicloud.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Package yum-utils-1.1.31-54.el7_8.noarch already installed and latest version
Nothing to do

​ 4. 添加yum源

1
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

1
2
3
4
5
[root@localhost home]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Loaded plugins: fastestmirror, langpacks
adding repo from: http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
grabbing file http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo

​ 5. 更新索引

1
yum makecache fast

1
2
3
4
5
6
7
8
9
10
11
12
13
[root@localhost home]# yum makecache fast
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.huaweicloud.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
docker-ce-stable | 3.5 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/2): docker-ce-stable/x86_64/updateinfo | 55 B 00:00:00
(2/2): docker-ce-stable/x86_64/primary_db | 46 kB 00:00:00
Metadata Cache Created

​ 6. 安装 docker-ce

1
yum install -y docker-ce

之后需要一段时间安装

​ 7. 启动 docker

systemctl start docker

​ 8. 验证是否安装成功

1
docker info

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
[root@localhost home]# docker info
Client:
Debug Mode: false

Server:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 19.03.13
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 8fba4e9a7d01810a393d5d25a3621dc101981175
runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 3.10.0-957.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 1.777GiB
Name: localhost.localdomain
ID: XIEA:KTDX:QOJ4:QTK7:WBKJ:IN2C:336V:UKI5:QZH3:TCOM:7KGM:T3OM
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false

安装docker-compose

1 安装epel源

1
yum install -y epel-release

2 安装docker-compose

1
yum install -y docker-compose
继开 wechat
欢迎加我的微信,共同交流技术